const path=require('path')
const HTMLPlugin=require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')

// const webpack=require('webpack')
// const ExtractPlugin=require('extract-text-webpack-plugin')
// const isDev=process.env.NODE_ENV === 'development'

module.exports={
    target: "web",
    entry:path.join(__dirname,'./src/index.js'),
    output:{
        filename: "bundle.js",
        path:path.join(__dirname,'dist')
    },
    module:{
        rules: [
            {  test:/\.vue$/, loader:'vue-loader' },
            {  test:/\.jsx$/, loader:'babel-loader' },
            {  test:/\.css$/, loader: "style-loader!css-loader!less-loader"  },
            {
              test:/\.js$/,
              loader:'babel',
              include: /node-modules/,
              query:{
                  presets:['es2015']
              }
            },
            { test:/\.(gif|jpg|jpeg|png|svg)$/,
                loader:"url-loader",
                options: {  limit:10000,  name:'[name].[ext]'   }
            },
            {
                test:/\.(woff|woff2|eot|ttf)$/,
                use: ["url-loader"]
            },
            {
                test:/vue-preview.src.*?js$/,
                loader:'babel'
            }

        ]
    },
    plugins:[
        new HTMLPlugin({
            template: path.join(__dirname, './src/index.html'), // 指定模板文件路径
            filename: 'index.html' // 设置生成的内存页面的名称
        }),
        new VueLoaderPlugin()
    ],
    devServer: {
        host:'localhost',
        port:3000,
        proxy:{
            /*'/api':{
                target:"https://api.jisuapi.com/news",
                changeOrigin:true,
                pathRewrite:{
                    '^/api':'',
                }
            },*/
            '/api':{
                target:"http://apis.juhe.cn/goodbook",
                changeOrigin:true,
                pathRewrite:{
                    '^/api':'',
                }
            },
            cssSourceMap:false
        }
    },
    resolve: {
        alias: { // 修改 Vue 被导入时候的包的路径
            // "vue$": "vue/dist/vue.js"
        }
    }
}





